package controller.managedBeans;

import java.io.Serializable;
import java.util.Date;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.*;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.richfaces.event.ItemChangeEvent;

import model.entities.*;
import model.dao.*;


@ManagedBean(name = "main")
@SessionScoped
public class MainController   implements Serializable {

	
  private static final long serialVersionUID = 1L;
  private NavigationEnum mainAreaEnum ;

	
  
  
  //inject the needed EJB
   @EJB
   private UserDao userFacade;
   private List<User> users ;
  
	
	@PostConstruct
    public void init() {
		System.out.println("initialization");
		users = userFacade.findAll();
		setMainAreaEnum(NavigationEnum.WELCOME);
    }


	public List<User> getUsers() {
		return users;
	}


	public void setUsers(List<User> users) {
		this.users = users;
	}


	public NavigationEnum getMainAreaEnum() {
		return mainAreaEnum;
	}


	public void setMainAreaEnum(NavigationEnum mainAreaEnum) {
		this.mainAreaEnum = mainAreaEnum;
	}
	

	 public void updateCurrent(ItemChangeEvent event) {
		 
		 System.out.println( event.getNewItemName());
		 setMainAreaEnum( NavigationEnum.valueOf(event.getNewItemName()) );
	    }
  
  
    public void goToViewTicket(ActionEvent actionEvent)
    {
    	System.out.println("came to VIEW_TICKETS");
    	setMainAreaEnum( NavigationEnum.VIEW_TICKETS);	
    }
  
  
}
